package cn.szabadsag.pet.controller;

import cn.szabadsag.pet.domain.SearchMasterMsg;
import cn.szabadsag.pet.query.SearchMasterMsgQuery;
import cn.szabadsag.pet.service.ISearchMasterMsgService;
import cn.szabadsag.utils.AjaxResult;
import cn.szabadsag.utils.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/searchMasterMsg")
public class SearchMasterMsgController {

    @Autowired
    private ISearchMasterMsgService seachMasterMsgService;


    /**
     * 查询所有宠物寻主信息
     * @return
     */
    @GetMapping
    public List<SearchMasterMsg> getAll(){
        return seachMasterMsgService.loadAll();
    }

    /**
     * 寻主发布接口
     * @return
     */
    @PostMapping("/publish")
    public AjaxResult publish(@RequestBody SearchMasterMsg searchMasterMsg, HttpServletRequest request){
        seachMasterMsgService.publish(searchMasterMsg,request);
        return AjaxResult.me();
    }

    /**
     * 高级查询
     * @param searchMasterMsgQuery
     * @return
     */
    @PostMapping("/queryPage")
    public QueryResult<SearchMasterMsg> queryPage(@RequestBody SearchMasterMsgQuery searchMasterMsgQuery,HttpServletRequest request){
        return  seachMasterMsgService.queryPage(searchMasterMsgQuery,request);
    }


}
